package com.id.coinscleaner.utils

import android.app.Application
import android.util.Log
import com.id.coinscleaner.utils.EventsService
import androidx.viewbinding.BuildConfig
import com.yandex.metrica.YandexMetrica
import com.yandex.metrica.YandexMetricaConfig

class MetricaEventsService(application: Application, key: String) : EventsService() {

    init {
        val config = YandexMetricaConfig.newConfigBuilder(key).build()
        YandexMetrica.activate(application, config)
        YandexMetrica.enableActivityAutoTracking(application)
    }

    override fun sendEvent(name: String) {
        if (BuildConfig.DEBUG) {
            Log.d("EventService", "name: $name")
        }
        YandexMetrica.reportEvent(name)
    }

    override fun sendEvent(name: String, params: Map<String, Any?>) {
        if (BuildConfig.DEBUG) {
            Log.d("EventService", "name: $name, params: $params")
        }
        YandexMetrica.reportEvent(name, params)
    }
}